<template>
	<view class="wrap">
		<view class="addresslist">
			<view class="form-label">支付宝</view>
			<view class="form-input">
				<view class="form-input-text">
					<view class="form-name">账号</view>
					<view class="form-item">
						<input type="text" placeholder="请输入账号" placeholder-class="pl" class="name"  v-model="alipay_account"></input>
					</view>
				</view>
				<view class="form-input-text">
					<view class="form-name">姓名</view>
					<view class="form-item">
						<input type="text" placeholder="请输入姓名" placeholder-class="pl" class="name"  v-model="alipay_name"></input>
					</view>
				</view>
			</view>
		</view>
		<view class="addresslist">
			<view class="form-label">微信</view>
			<view class="form-input">
				<view class="form-input-text">
					<view class="form-name">手机号码</view>
					<view class="form-item">
						<input type="text" placeholder="请输入手机号码" placeholder-class="pl" class="name" v-model="wx_phone"></input>
					</view>
				</view>
				<view class="form-input-text">
					<view class="form-name">姓名</view>
					<view class="form-item">
						<input type="text" placeholder="请输入姓名" placeholder-class="pl" class="name"  v-model="wx_name"></input>
					</view>
				</view>
			</view>
		</view>
		<view class="addresslist">
			<view class="form-label">银行卡</view>
			<view class="form-input">
				<view class="form-input-text">
					<view class="form-name">开户行</view>
					<view class="form-item">
						<input type="text" placeholder="请输入开户行" placeholder-class="pl" class="name" v-model="bank_open_name"></input>
					</view>
				</view>
				<view class="form-input-text">
					<view class="form-name">卡号</view>
					<view class="form-item">
						<input type="text" placeholder="请输入卡号" placeholder-class="pl" class="name"  v-model="bank_number"></input>
					</view>
				</view>
				<view class="form-input-text">
					<view class="form-name">姓名</view>
					<view class="form-item">
						<input type="text" placeholder="请输入姓名" placeholder-class="pl" class="name"  v-model="bank_name"></input>
					</view>
				</view>
			</view>
		</view>
		<view class="info-account">
			<view style="font-size: 23rpx;">
				分销所得佣金将提现到您预留的收款账号，请填写正确的账号信息和姓名
			</view>
			<button @click="close" class="msg-btn mainColor border-25">
				确定
			</button>
		</view>
	</view>
</template>

<script>
	let App = getApp().globalData;
	import Icon from '@/components/Icon/Icon.vue'
	export default {
		// name:'提现设置'
		components:{
			Icon
		},
		data() {
			return {
				alipay_account:'',
				alipay_name:'',
				wx_phone:'',
				wx_name:'',
				bank_open_name:'',
				bank_number:'',
				bank_name:''
			}
		},
		mounted() {
			this.getWithdrawSetInfo();
		},
		methods: {
			close(){
				let _self = this;
				let obj = {
					alipay_account: _self.alipay_account,
					alipay_name:_self.alipay_name,
					wx_phone:_self.wx_phone,
					wx_name:_self.wx_name,
					bank_open_name:_self.bank_open_name,
					bank_number:_self.bank_number,
					bank_name:_self.bank_name,
				};
				if ((_self.wx_phone)&&(!/^1[3456789]\d{9}$/.test(_self.wx_phone))) {
					uni.showToast({
						title: '手机格式不正确',
						icon:'none',
						duration: 1500
					});
					return true;
				}
				this.$request('Distribution/MiniDistributor/setWithdrawal', obj).then(res => {
					if (res.status === 1) {
						uni.showModal({
							title: '提示',
							content: res.msg,
							showCancel: false,
							success: (res) => {
								uni.navigateBack();
							}
						});
					} else {
						App.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
				});
			},
			getWithdrawSetInfo(){
				this.$request('Distribution/MiniDistributor/getWithdrawal', {}).then(res => {
					if (res.status === 1) {
						this.alipay_account = res.data.alipay_account;
						this.alipay_name = res.data.alipay_name;
						this.wx_phone = res.data.wx_phone;
						this.wx_name = res.data.wx_name;
						this.bank_open_name = res.data.bank_open_name;
						this.bank_number = res.data.bank_number;
						this.bank_name = res.data.bank_name;
					} else {
						App.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
				});
			}
		}
	}
</script>

<style lang="less">
@import 'form.less';
</style>
